<template>
    <div class="calendar-bottom">
        <div class="left">
            <h2>{{result.lunar}}</h2>
            <h3>{{ result.lunarYear }} {{ result.animalsYear }}</h3>
        </div>
        <div class="right">
            <div>
                宜:<span>{{ result.suit }}</span> 
            </div>
            <div>
                忌:<span>{{ result.avoid }}</span>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { storeToRefs } from 'pinia';
import { useCalendarStore } from '@/stores/calendar';

const {formatDate} = storeToRefs(useCalendarStore())

import axios from 'axios'

const result = ref({
    lunar:'',
    lunarYear:'',
    animalsYear:'',
    suit:'',
    avoid:'',
})

const key = '6558a53834be31a7eaa4cf7831f3815a'
onMounted(async() => {
    const res = await axios.get(
        `/calendar/day?date=${formatDate.value}&key=${key}`
    )
    console.log(res.data,'res')
    result.value = res.data.result.data
})

</script>

<style lass="scss" scoped>
.calendar-bottom{

    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px;
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 16px;

    .left{
        flex: 1;
    }
    .right{
        flex: 3;
        span{
            font-size: 12px;
        }
    }
}
</style>